`timescale 1 ns / 100ps
//h28 w64
module TB();
reg clk,dot_clk;
reg rst;
reg [63:0] img[27:0];// image size 64*28
reg [7:0] col;
reg [7:0] BMP_FILE [285:0];
reg [31:0] data_start;
wire [27:0] dot_print;
integer f_handle,mem_handle;
reg [1023:0] filename; 
initial
begin
    $dumpfile("wave.vcd");
    $dumpvars(0,TB); 
end
initial
begin
  clk = 0;
  rst =1;
  #5 clk =1;
  #5 rst = 0;
  repeat(130) #8 clk=!clk;
  $stop;
end
initial
begin
  dot_clk=0;
  forever #1 dot_clk=!dot_clk;
end
initial
begin
  f_handle = $fopen(".img_tmp","rb");
  mem_handle=$fread(BMP_FILE,f_handle);
  data_start={BMP_FILE[13],BMP_FILE[12],BMP_FILE[11],BMP_FILE[10]};
  img[0] = {BMP_FILE[data_start+0],BMP_FILE[data_start+1],BMP_FILE[data_start+2],BMP_FILE[data_start+3],BMP_FILE[data_start+4],BMP_FILE[data_start+5],BMP_FILE[data_start+6],BMP_FILE[data_start+7]};
img[1] = {BMP_FILE[data_start+8],BMP_FILE[data_start+9],BMP_FILE[data_start+10],BMP_FILE[data_start+11],BMP_FILE[data_start+12],BMP_FILE[data_start+13],BMP_FILE[data_start+14],BMP_FILE[data_start+15]};
img[2] = {BMP_FILE[data_start+16],BMP_FILE[data_start+17],BMP_FILE[data_start+18],BMP_FILE[data_start+19],BMP_FILE[data_start+20],BMP_FILE[data_start+21],BMP_FILE[data_start+22],BMP_FILE[data_start+23]};
img[3] = {BMP_FILE[data_start+24],BMP_FILE[data_start+25],BMP_FILE[data_start+26],BMP_FILE[data_start+27],BMP_FILE[data_start+28],BMP_FILE[data_start+29],BMP_FILE[data_start+30],BMP_FILE[data_start+31]};
img[4] = {BMP_FILE[data_start+32],BMP_FILE[data_start+33],BMP_FILE[data_start+34],BMP_FILE[data_start+35],BMP_FILE[data_start+36],BMP_FILE[data_start+37],BMP_FILE[data_start+38],BMP_FILE[data_start+39]};
img[5] = {BMP_FILE[data_start+40],BMP_FILE[data_start+41],BMP_FILE[data_start+42],BMP_FILE[data_start+43],BMP_FILE[data_start+44],BMP_FILE[data_start+45],BMP_FILE[data_start+46],BMP_FILE[data_start+47]};
img[6] = {BMP_FILE[data_start+48],BMP_FILE[data_start+49],BMP_FILE[data_start+50],BMP_FILE[data_start+51],BMP_FILE[data_start+52],BMP_FILE[data_start+53],BMP_FILE[data_start+54],BMP_FILE[data_start+55]};
img[7] = {BMP_FILE[data_start+56],BMP_FILE[data_start+57],BMP_FILE[data_start+58],BMP_FILE[data_start+59],BMP_FILE[data_start+60],BMP_FILE[data_start+61],BMP_FILE[data_start+62],BMP_FILE[data_start+63]};
img[8] = {BMP_FILE[data_start+64],BMP_FILE[data_start+65],BMP_FILE[data_start+66],BMP_FILE[data_start+67],BMP_FILE[data_start+68],BMP_FILE[data_start+69],BMP_FILE[data_start+70],BMP_FILE[data_start+71]};
img[9] = {BMP_FILE[data_start+72],BMP_FILE[data_start+73],BMP_FILE[data_start+74],BMP_FILE[data_start+75],BMP_FILE[data_start+76],BMP_FILE[data_start+77],BMP_FILE[data_start+78],BMP_FILE[data_start+79]};
img[10] = {BMP_FILE[data_start+80],BMP_FILE[data_start+81],BMP_FILE[data_start+82],BMP_FILE[data_start+83],BMP_FILE[data_start+84],BMP_FILE[data_start+85],BMP_FILE[data_start+86],BMP_FILE[data_start+87]};
img[11] = {BMP_FILE[data_start+88],BMP_FILE[data_start+89],BMP_FILE[data_start+90],BMP_FILE[data_start+91],BMP_FILE[data_start+92],BMP_FILE[data_start+93],BMP_FILE[data_start+94],BMP_FILE[data_start+95]};
img[12] = {BMP_FILE[data_start+96],BMP_FILE[data_start+97],BMP_FILE[data_start+98],BMP_FILE[data_start+99],BMP_FILE[data_start+100],BMP_FILE[data_start+101],BMP_FILE[data_start+102],BMP_FILE[data_start+103]};
img[13] = {BMP_FILE[data_start+104],BMP_FILE[data_start+105],BMP_FILE[data_start+106],BMP_FILE[data_start+107],BMP_FILE[data_start+108],BMP_FILE[data_start+109],BMP_FILE[data_start+110],BMP_FILE[data_start+111]};
img[14] = {BMP_FILE[data_start+112],BMP_FILE[data_start+113],BMP_FILE[data_start+114],BMP_FILE[data_start+115],BMP_FILE[data_start+116],BMP_FILE[data_start+117],BMP_FILE[data_start+118],BMP_FILE[data_start+119]};
img[15] = {BMP_FILE[data_start+120],BMP_FILE[data_start+121],BMP_FILE[data_start+122],BMP_FILE[data_start+123],BMP_FILE[data_start+124],BMP_FILE[data_start+125],BMP_FILE[data_start+126],BMP_FILE[data_start+127]};
img[16] = {BMP_FILE[data_start+128],BMP_FILE[data_start+129],BMP_FILE[data_start+130],BMP_FILE[data_start+131],BMP_FILE[data_start+132],BMP_FILE[data_start+133],BMP_FILE[data_start+134],BMP_FILE[data_start+135]};
img[17] = {BMP_FILE[data_start+136],BMP_FILE[data_start+137],BMP_FILE[data_start+138],BMP_FILE[data_start+139],BMP_FILE[data_start+140],BMP_FILE[data_start+141],BMP_FILE[data_start+142],BMP_FILE[data_start+143]};
img[18] = {BMP_FILE[data_start+144],BMP_FILE[data_start+145],BMP_FILE[data_start+146],BMP_FILE[data_start+147],BMP_FILE[data_start+148],BMP_FILE[data_start+149],BMP_FILE[data_start+150],BMP_FILE[data_start+151]};
img[19] = {BMP_FILE[data_start+152],BMP_FILE[data_start+153],BMP_FILE[data_start+154],BMP_FILE[data_start+155],BMP_FILE[data_start+156],BMP_FILE[data_start+157],BMP_FILE[data_start+158],BMP_FILE[data_start+159]};
img[20] = {BMP_FILE[data_start+160],BMP_FILE[data_start+161],BMP_FILE[data_start+162],BMP_FILE[data_start+163],BMP_FILE[data_start+164],BMP_FILE[data_start+165],BMP_FILE[data_start+166],BMP_FILE[data_start+167]};
img[21] = {BMP_FILE[data_start+168],BMP_FILE[data_start+169],BMP_FILE[data_start+170],BMP_FILE[data_start+171],BMP_FILE[data_start+172],BMP_FILE[data_start+173],BMP_FILE[data_start+174],BMP_FILE[data_start+175]};
img[22] = {BMP_FILE[data_start+176],BMP_FILE[data_start+177],BMP_FILE[data_start+178],BMP_FILE[data_start+179],BMP_FILE[data_start+180],BMP_FILE[data_start+181],BMP_FILE[data_start+182],BMP_FILE[data_start+183]};
img[23] = {BMP_FILE[data_start+184],BMP_FILE[data_start+185],BMP_FILE[data_start+186],BMP_FILE[data_start+187],BMP_FILE[data_start+188],BMP_FILE[data_start+189],BMP_FILE[data_start+190],BMP_FILE[data_start+191]};
img[24] = {BMP_FILE[data_start+192],BMP_FILE[data_start+193],BMP_FILE[data_start+194],BMP_FILE[data_start+195],BMP_FILE[data_start+196],BMP_FILE[data_start+197],BMP_FILE[data_start+198],BMP_FILE[data_start+199]};
img[25] = {BMP_FILE[data_start+200],BMP_FILE[data_start+201],BMP_FILE[data_start+202],BMP_FILE[data_start+203],BMP_FILE[data_start+204],BMP_FILE[data_start+205],BMP_FILE[data_start+206],BMP_FILE[data_start+207]};
img[26] = {BMP_FILE[data_start+208],BMP_FILE[data_start+209],BMP_FILE[data_start+210],BMP_FILE[data_start+211],BMP_FILE[data_start+212],BMP_FILE[data_start+213],BMP_FILE[data_start+214],BMP_FILE[data_start+215]};
img[27] = {BMP_FILE[data_start+216],BMP_FILE[data_start+217],BMP_FILE[data_start+218],BMP_FILE[data_start+219],BMP_FILE[data_start+220],BMP_FILE[data_start+221],BMP_FILE[data_start+222],BMP_FILE[data_start+223]};
end
always @(posedge clk ,rst)
begin
  if(rst)
  begin
      col = 63;
  end
  else
  begin
    col = col -1;  
    if(!col)
    begin
      $fclose(f_handle);
      $stop;
    end
  end 
end
assign dot_print[0] = img[0][col]?0:dot_clk;
assign dot_print[1] = img[1][col]?0:dot_clk;
assign dot_print[2] = img[2][col]?0:dot_clk;
assign dot_print[3] = img[3][col]?0:dot_clk;
assign dot_print[4] = img[4][col]?0:dot_clk;
assign dot_print[5] = img[5][col]?0:dot_clk;
assign dot_print[6] = img[6][col]?0:dot_clk;
assign dot_print[7] = img[7][col]?0:dot_clk;
assign dot_print[8] = img[8][col]?0:dot_clk;
assign dot_print[9] = img[9][col]?0:dot_clk;
assign dot_print[10] = img[10][col]?0:dot_clk;
assign dot_print[11] = img[11][col]?0:dot_clk;
assign dot_print[12] = img[12][col]?0:dot_clk;
assign dot_print[13] = img[13][col]?0:dot_clk;
assign dot_print[14] = img[14][col]?0:dot_clk;
assign dot_print[15] = img[15][col]?0:dot_clk;
assign dot_print[16] = img[16][col]?0:dot_clk;
assign dot_print[17] = img[17][col]?0:dot_clk;
assign dot_print[18] = img[18][col]?0:dot_clk;
assign dot_print[19] = img[19][col]?0:dot_clk;
assign dot_print[20] = img[20][col]?0:dot_clk;
assign dot_print[21] = img[21][col]?0:dot_clk;
assign dot_print[22] = img[22][col]?0:dot_clk;
assign dot_print[23] = img[23][col]?0:dot_clk;
assign dot_print[24] = img[24][col]?0:dot_clk;
assign dot_print[25] = img[25][col]?0:dot_clk;
assign dot_print[26] = img[26][col]?0:dot_clk;
assign dot_print[27] = img[27][col]?0:dot_clk;
endmodule
